using System;
using System.IO;
using System.Collections.Generic;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Text;

namespace ArchSoft
{
    static class Program
    {
        public static bool CanRunMainFrm = false;
        public static string ProjectID = "";
        public static string CurrentUser = "";

        static void registerextension()
        {
            //Create necessary keys
            //Amt Ext
            RegistryKey RegKey = Registry.ClassesRoot.CreateSubKey(".imt");
            RegKey.SetValue("", "AmtFiles");
            RegKey.Close();

            //Amt Subkey
            RegKey = Registry.ClassesRoot.CreateSubKey("AmtFiles");
            RegKey.SetValue("", "Trang Interior Template");
            RegKey.Close();

            //Create open command for AMT files

            RegKey = Registry.ClassesRoot.CreateSubKey("AmtFiles" + Path.DirectorySeparatorChar + "Shell"
            + Path.DirectorySeparatorChar + "Open with Trang Project Interior 2008");
            RegKey = RegKey.CreateSubKey("Command");
            //Set the application for handling the open command and pass
            //the file path as a parameter
            RegKey.SetValue("",
            "\"" + Application.ExecutablePath + "\"" + " \"%L\"");
            RegKey.Close();

            //Associate icon for ssb files

            RegKey = Registry.ClassesRoot.CreateSubKey("AmtFiles" + Path.DirectorySeparatorChar
            + "DefaultIcon");
            RegKey.SetValue("", Application.StartupPath + "\\AMT.ico");
            RegKey.Close();


            //Ams Extension
            RegKey = Registry.ClassesRoot.CreateSubKey(".ims");
            RegKey.SetValue("", "AmsFiles");
            RegKey.Close();
            //Ams Subkey
            RegKey = Registry.ClassesRoot.CreateSubKey("AmsFiles");
            RegKey.SetValue("", "Trang Interior Infomation");
            RegKey.Close();
            //Create open command for ssb files

            RegKey = Registry.ClassesRoot.CreateSubKey("AmsFiles" + Path.DirectorySeparatorChar + "Shell"
            + Path.DirectorySeparatorChar + "Open with Trang Project Interior 2008");
            RegKey = RegKey.CreateSubKey("Command");
            //Set the application for handling the open command and pass
            //the file path as a parameter
            RegKey.SetValue("",
            "\"" + Application.ExecutablePath + "\"" + " \"%L\"");
            RegKey.Close();

            //Associate icon for AMS files

            RegKey = Registry.ClassesRoot.CreateSubKey("AmsFiles" + Path.DirectorySeparatorChar
            + "DefaultIcon");
            RegKey.SetValue("", Application.StartupPath + "\\AMS.ico");
            RegKey.Close();
        }

        [STAThread]
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            LoginFrm fDangNhap = new LoginFrm();
            Application.Run(fDangNhap);
            if (fDangNhap.CanRun)
            {
                FrmMain formm = new FrmMain();
                formm.MaID = fDangNhap.MaID;

                formm.UserName = fDangNhap.UserName;
                Application.Run(formm);
            }
            Application.Run(new FrmMain());
        }  
    }
}